<template>
  <el-dialog title="移动素材" :visible.sync="visible" width="25%" :before-close="handleClose" :close-on-click-modal="false" :inline="true">
    <el-form label-position="left" size="small">
      <el-form-item label="素材分组">
        <el-select v-model="category"><el-option v-for="item in options" :key="item.id" :label="item.title" :value="item.id" /></el-select>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="onSubmit">保存</el-button>
      <el-button @click="handleClose">取消</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { mapState } from 'vuex';
export default {
  props: {
    submit: {
      type: Function,
      require: true,
      default: _ => {}
    }
  },
  data() {
    return {
      visible: true,
      category: -1
    };
  },
  computed: {
    ...mapState('pageList', {
      options: state => (state.responseData ? state.responseData.category[0].children : [])
    })
  },
  methods: {
    handleClose: function() {
      this.$emit('update:visible', false);
    },
    onSubmit: function() {
      this.$emit('submit', this.category);
    }
  }
};
</script>
